package com.yq.homework.day24;


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;

/**
 * @author 3307235355@qq.com
 * @since 2022/06/24 19:35
 * 在一个磁盘的文件里保存26个英文小写字母（乱序），
 * 将他们读入内存中，进行排序，
 * 把排好顺序的数再重新追加写到磁盘的该文件中。
 */
public class Demo03 {
    public static void main(String[] args) throws IOException {
        FileInputStream in = new FileInputStream("a.txt");
        FileOutputStream out = new FileOutputStream("a.txt", true);
        byte[] bytes = new byte[30];
        int read = in.read(bytes);
        String s = new String(bytes, 0, read);
        char[] chars = s.toCharArray();
        // System.out.println("chars"+chars.length);
        Arrays.sort(chars);
        String s2 = new String(chars);
        out.write(System.lineSeparator().getBytes());
        out.write(s2.getBytes());
        in.close();
        out.close();
    }
}
